﻿@using SAD_SiS.Models;
<div class="container">
    <ul id="menu">
        <li><a href="@Url.Action("Index", "Home")" class="drop">Home</a></li>
        <!-- End Home Item -->
        @{
            using (SADEntities dbContext = new SADEntities())
            {
                var list = (from c in dbContext.Categories where c.ParentCate == null select c).ToList();
                foreach (var item in list)
                {
            <li><a href="#" class="drop">@item.CateName</a>
                @{var sublist = (from s in dbContext.Categories where s.ParentCate == item.CateID && s.Active == true select s).ToList();
                  int count = sublist.Count;
                  int page = count / 3;
                  int firstpage = count - (page * 2);
                }
                <div class="dropdown_3columns">
                    <div class="col_1">
                        @for (int i = 0; i < firstpage; i++)
                        {
                            <a href="@Url.Action("Views", "Category", new { id = sublist[i].LinkName }, null)">
                                <h3>@sublist[i].CateName</h3>
                            </a>
                        }
                    </div>
                    <div class="col_1">
                        @for (int i = firstpage; i < firstpage + page; i++)
                        {
                            <a href="@Url.Action("Views", "Category", new { id = sublist[i].LinkName }, null)">
                                <h3>@sublist[i].CateName</h3>
                            </a>
                        }
                    </div>
                    <div class="col_1">
                        @for (int i = firstpage + page; i < firstpage + page + page; i++)
                        {
                            <a href="@Url.Action("Views", "Category", new { id = sublist[i].LinkName }, null)">
                                <h3>@sublist[i].CateName</h3>
                            </a>
                        }
                    </div>
                </div>
            </li>
                }
            }
        }
        <!-- End 5 columns Item -->
        <!-- End 4 columns Item -->
        @using (Html.BeginForm("Search", "Home", FormMethod.Post, new { @class = "", id = "searchform" }))
        {
            <div class="input-append" style="vertical-align: inherit">
                <select name="SearchType" style="width:auto">
                    <option value="Product" @(ViewBag.SearchType == "Product" ? "selected" : "")>Sản
                        phẩm</option>
                    <option value="Shop" @(ViewBag.SearchType == "Shop" ? "selected" : "")>Shop</option>
                </select>
            </div>
            <div class="input-append" style="vertical-align: inherit">
                <input type="text" class="span3" name="searchkey" value="@ViewBag.SearchKey"/>
                <button type="submit" class="btn">
                    <i class='icon-search'></i>&nbsp;
                </button>
            </div>
        }
        <!-- End 3 columns Item -->
    </ul>
</div>
